<template>
  <div class="cont">
    <div>
      <yanDanGoodsEditComponent v-if="active" :goods-details="goodsDetails"/>

    </div>
  </div>
</template>
<script>


import yanDanGoodsEditComponent from '../../components/goods/yanDanGoodsEditComponent.vue'
import {queryGoodsDetail} from "../../services/goods";

export default {
  name: "YanDanGoodsEdit",
  components: {
    yanDanGoodsEditComponent
  },
  data () {
    return {
      active:false,
      goodsDetails:Object,

    }
  },

  created() {
    this.getGoodsDetails(this.$route.query.id)
  },

  methods: {
      // 获取商品详情
      async getGoodsDetails(goodsId) {
        const data = {
          id:goodsId
        }
        console.log('request goods detail param is ',data)
        const res = await queryGoodsDetail(data);
        console.log('queryGoodsDetail result is ',res)
        if (res.code === 0) {
          this.goodsDetails=res.data;
          this.goodsDetails.goodsId=res.data.id
          this.active=true
        }
      },
    add (...values) {
      let sum = 0
      console.log(values)
      for (var val of values) {
        sum += val
      }
      return sum
    },
    change (va) {
      console.log(va)
    },
    handleClick (tab, event) {
      console.log(tab, event)
    }
  }
}
</script>
 